<?php
/**
 * Created by PhpStorm.
 * User: 张辉
 * Date: 2018/7/18
 * Time: 14:29
 */

namespace app\common\service\sms\driver;

use app\common\service\sms\Driver;
use app\common\service\sms\lib\YunPianSms;

class YunPian extends Driver
{
    /**
     * @var YunPianSms
     */
    public $sms;

    public function __construct()
    {
        $this->sms = new YunPianSms();
    }

    /**
     * 发送验证码短信
     * @param array $param
     * @return bool
     */
    public function sendCode( $param )
    {
        $res = $this->sms->send_code( $param['mobile'], $this->getCodeContent($param['content']));
        return $res['code'] == 0 ? true : false;
    }


    /**
     * 获取发送文案
     * @param $code
     * @return string
     */
    private function getCodeContent( $code )
    {
        return "【HOLD】您的验证码是{$code}，60秒内有效，请勿泄露。如非本人操作请忽略。";
    }

}